package com.zbf11a.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/7/27  15:31
 * 描述:
 */
@Configuration
public class MQConfig {

    @Bean("queue1")
    public Queue getQueue(){

        return new Queue("REDIS-MQ",true,false,false);

    }

    @Bean("exchange1")
    public Exchange getExchange(){

        Exchange build = ExchangeBuilder.directExchange("REDIS-EXCHANGE").durable(true).build();

        return build;
    }


    @Bean
    public Binding getBinding(@Qualifier("queue1") Queue queue,@Qualifier("exchange1") Exchange exchange){
        Binding redis = BindingBuilder.bind(queue).to(exchange).with("REDIS").noargs();
        return redis;
    }
}
